# -*- coding: utf-8 -*-
'''
autor: José Jasnau Caeiro
data: 23-04-2012
Código fornecido na aula 
'''

class Stack:
    
    def __init__(self, N):
        self.top = -1
        self.S = [0 for k in range(N)]
        pass
    
    def stack_empty(self):
        if self.top == 0:
            return True
        else:
            return False

    '''
    método adicionado
    verifica se a stack está cheia
    '''
    def stack_full(self):
        if self.top >= len (self.S) -1:
                return True
        else:
                return False
        pass
    
    def push(self, x):
        self.top += 1
        self.S[self.top] = x
        pass
    
    def pop(self):
        if self.stack_empty():
            return "underflow"
        else:
            self.top -= 1
            return self.S[self.top+1]
        pass
    def __str__(self):
        s = ""
        s += str(self.top+1) + ": "
        for k in range(0, self.top+1):
            s += ' ' + str(self.S[k])
        return s
    pass
